<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>商城设置</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="{__STATIC__}/layuiAdmin/layui/css/layui.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/adminui/dist/css/admin.css" rel="stylesheet">
	<link href="{__STATIC__}/layuiAdmin/style/style.css" rel="stylesheet">
</head>
<body>
<div class="layui-fluid">
	<form class="layui-form" style="padding-bottom: 45px;">
		<div class="layui-card">
			<div class="layui-card-body">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li class="layui-this">商城设置</li>
					</ul>
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<div class="layui-form-item">
								<label class="layui-form-label"><span>*</span> 默认库存：</label>
								<div class="layui-input-inline w120">
									<input type="text" name="m_default_stock" lay-verify="number" placeholder="请输入默认库存" class="layui-input" value="{$shop.default_stock}">
								</div>
								<div class="layui-form-mid layui-word-aux">添加商品时的默认库存</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"><span>*</span> 库存预警：</label>
								<div class="layui-input-inline w120">
									<input type="text" name="m_warning_stock" lay-verify="number" placeholder="请输入库存预警" class="layui-input" value="{$shop.warning_stock}">
								</div>
								<div class="layui-form-mid layui-word-aux">库存小于此数将预警</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">下单未支付：</label>
								<div class="layui-input-inline w120">
									<select name="m_close_time">
										<option value="5" {eq name="$shop.close_time" value="5"}selected{/eq}>5分钟</option>
										<option value="10" {eq name="$shop.close_time" value="10"}selected{/eq}>10分钟</option>
										<option value="30" {eq name="$shop.close_time" value="30"}selected{/eq}>30分钟</option>
										<option value="60" {eq name="$shop.close_time" value="60"}selected{/eq}>1小时</option>
										<option value="1440" {eq name="$shop.close_time" value="1440"}selected{/eq}>1天</option>
										<option value="2880" {eq name="$shop.close_time" value="2880"}selected{/eq}>2天</option>
										<option value="4320" {eq name="$shop.close_time" value="4320"}selected{/eq}>3天</option>
									</select>
								</div>
								<div class="layui-form-mid layui-word-aux">后自动关闭</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">发货成功：</label>
								<div class="layui-input-inline" style="width: 120px;">
									<select name="m_send_time">
										<option value="1" {eq name="$shop.send_time" value="1"}selected{/eq}>1天</option>
										<option value="2" {eq name="$shop.send_time" value="2"}selected{/eq}>2天</option>
										<option value="3" {eq name="$shop.send_time" value="3"}selected{/eq}>3天</option>
										<option value="4" {eq name="$shop.send_time" value="4"}selected{/eq}>4天</option>
										<option value="5" {eq name="$shop.send_time" value="5"}selected{/eq}>5天</option>
										<option value="6" {eq name="$shop.send_time" value="6"}selected{/eq}>6天</option>
										<option value="7" {eq name="$shop.send_time" value="7"}selected{/eq}>7天</option>
										<option value="8" {eq name="$shop.send_time" value="8"}selected{/eq}>8天</option>
										<option value="9" {eq name="$shop.send_time" value="9"}selected{/eq}>9天</option>
										<option value="10" {eq name="$shop.send_time" value="10"}selected{/eq}>10天</option>
										<option value="11" {eq name="$shop.send_time" value="11"}selected{/eq}>11天</option>
										<option value="12" {eq name="$shop.send_time" value="12"}selected{/eq}>12天</option>
										<option value="13" {eq name="$shop.send_time" value="13"}selected{/eq}>13天</option>
										<option value="14" {eq name="$shop.send_time" value="14"}selected{/eq}>14天</option>
										<option value="15" {eq name="$shop.send_time" value="15"}selected{/eq}>15天</option>
									</select>
								</div>
								<div class="layui-form-mid layui-word-aux">后自动收货</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">收货成功：</label>
								<div class="layui-input-inline" style="width: 120px;">
									<select name="m_finish_time">
										<option value="1" {eq name="$shop.finish_time" value="1"}selected{/eq}>1天</option>
										<option value="2" {eq name="$shop.finish_time" value="2"}selected{/eq}>2天</option>
										<option value="3" {eq name="$shop.finish_time" value="3"}selected{/eq}>3天</option>
										<option value="4" {eq name="$shop.finish_time" value="4"}selected{/eq}>4天</option>
										<option value="5" {eq name="$shop.finish_time" value="5"}selected{/eq}>5天</option>
										<option value="6" {eq name="$shop.finish_time" value="6"}selected{/eq}>6天</option>
										<option value="7" {eq name="$shop.finish_time" value="7"}selected{/eq}>7天</option>
										<option value="8" {eq name="$shop.finish_time" value="8"}selected{/eq}>8天</option>
										<option value="9" {eq name="$shop.finish_time" value="9"}selected{/eq}>9天</option>
										<option value="10" {eq name="$shop.finish_time" value="10"}selected{/eq}>10天</option>
										<option value="11" {eq name="$shop.finish_time" value="11"}selected{/eq}>11天</option>
										<option value="12" {eq name="$shop.finish_time" value="12"}selected{/eq}>12天</option>
										<option value="13" {eq name="$shop.finish_time" value="13"}selected{/eq}>13天</option>
										<option value="14" {eq name="$shop.finish_time" value="14"}selected{/eq}>14天</option>
										<option value="15" {eq name="$shop.finish_time" value="15"}selected{/eq}>15天</option>
									</select>
								</div>
								<div class="layui-form-mid layui-word-aux">后自动好评</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">积分抵扣：</label>
								<div class="layui-input-inline w120">
									<select name="m_exchange" lay-filter="m_exchange">
										<option value="1" {eq name="$shop.is_exchange" value="1"}selected{/eq}>开启</option>
										<option value="0" {eq name="$shop.is_exchange" value="0"}selected{/eq}>关闭</option>
									</select>
								</div>
								<div class="layui-form-mid layui-word-aux">下单时抵扣</div>
							</div>
							<div id="span_exchange" {eq name="$shop.is_exchange" value="0"}style="display: none"{/eq}>
								<div class="layui-form-item">
									<label class="layui-form-label">积分兑换比例：</label>
									<div class="layui-input-block">
										<input type="radio" name="m_exchange_ratio" value="1" title="1积分 = 1元" {eq name="$shop.exchange_ratio" value="1"}checked{/eq}>
										<input type="radio" name="m_exchange_ratio" value="10" title="10积分 = 1元" {eq name="$shop.exchange_ratio" value="10"}checked{/eq}>
										<input type="radio" name="m_exchange_ratio" value="100" title="100积分 = 1元" {eq name="$shop.exchange_ratio" value="100"}checked{/eq}>
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">最低使用积分：</label>
									<div class="layui-input-inline w120">
										<input type="text" name="m_mini_integral" lay-verify="number" placeholder="请输入最低积分" value="{$shop.mini_integral}" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">最少要这么多积分才可使用</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">积分使用比例：</label>
									<div class="layui-input-inline w120">
										<input type="text" name="m_use_ratio" lay-verify="number" placeholder="积分使用比例" value="{$shop.use_ratio}" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">%，如：50 表示最多可以抵扣订单50%的金额</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">满额包邮：</label>
								<div class="layui-input-inline w120">
									<select name="m_free_shipping" lay-filter="m_free">
										<option value="1" {eq name="$shop.is_free_shipping" value="1"}selected{/eq}>开启</option>
										<option value="0" {eq name="$shop.is_free_shipping" value="0"}selected{/eq}>关闭</option>
									</select>
								</div>
							</div>
							<div id="span_free" {eq name="$shop.is_free_shipping" value="0"}style="display: none"{/eq}>
								<div class="layui-form-item">
									<label class="layui-form-label">包邮金额：</label>
									<div class="layui-input-inline w120">
										<input type="text" name="m_free_price" lay-verify="number" placeholder="请输入包邮金额" value="{$shop.free_price}" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">订单金额满这么多包邮</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">退换开关：</label>
								<div class="layui-input-inline w120">
									<select name="m_is_refund" lay-filter="m_refund">
										<option value="1" {eq name="$shop.is_refund" value="1"}selected{/eq}>开启</option>
										<option value="0" {eq name="$shop.is_refund" value="0"}selected{/eq}>关闭</option>
									</select>
								</div>
							</div>
					        <div id="span_refund" {eq name="$shop.is_refund" value="0"}style="display: none"{/eq}>
								<div class="layui-form-item">
									<label class="layui-form-label">退换有效期：</label>
									<div class="layui-input-inline" style="width: 120px;">
										<select name="m_refund_time">
											<option value="1" {eq name="$shop.refund_time" value="1"}selected{/eq}>1天</option>
											<option value="2" {eq name="$shop.refund_time" value="2"}selected{/eq}>2天</option>
											<option value="3" {eq name="$shop.refund_time" value="3"}selected{/eq}>3天</option>
											<option value="4" {eq name="$shop.refund_time" value="4"}selected{/eq}>4天</option>
											<option value="5" {eq name="$shop.refund_time" value="5"}selected{/eq}>5天</option>
											<option value="6" {eq name="$shop.refund_time" value="6"}selected{/eq}>6天</option>
											<option value="7" {eq name="$shop.refund_time" value="7"}selected{/eq}>7天</option>
											<option value="8" {eq name="$shop.refund_time" value="8"}selected{/eq}>8天</option>
											<option value="9" {eq name="$shop.refund_time" value="9"}selected{/eq}>9天</option>
											<option value="10" {eq name="$shop.refund_time" value="10"}selected{/eq}>10天</option>
											<option value="11" {eq name="$shop.refund_time" value="11"}selected{/eq}>11天</option>
											<option value="12" {eq name="$shop.refund_time" value="12"}selected{/eq}>12天</option>
											<option value="13" {eq name="$shop.refund_time" value="13"}selected{/eq}>13天</option>
											<option value="14" {eq name="$shop.refund_time" value="14"}selected{/eq}>14天</option>
											<option value="15" {eq name="$shop.refund_time" value="15"}selected{/eq}>15天</option>
										</select>
									</div>
									<div class="layui-form-mid layui-word-aux">发货后多少天可以申请退换</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">退货收件人：</label>
									<div class="layui-input-inline">
										<input type="text" name="m_refund_name" value="{$shop.refund_name}" placeholder="请输入退货收件人" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">退货收件人姓名</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">收件人电话：</label>
									<div class="layui-input-inline">
										<input type="text" name="m_refund_tel" value="{$shop.refund_tel}" placeholder="请输入收件人电话" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">退货收件人电话</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">收件人地址：</label>
									<div class="layui-input-inline">
										<input type="text" name="m_refund_address" value="{$shop.refund_address}" placeholder="请输入收件人地址" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux">退货收件人地址</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">仅退款原因：</label>
									<div class="layui-input-inline w500">
										<textarea name="m_refund_reason1" placeholder="" class="layui-textarea" style="height: 150px;line-height: 26px;">{:str_replace(",",PHP_EOL, $shop.refund_reason1)}</textarea>
									</div>
									<div class="layui-form-mid layui-word-aux span_note">
										一行一个
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">退货退款原因：</label>
									<div class="layui-input-inline w500">
										<textarea name="m_refund_reason2" placeholder="" class="layui-textarea" style="height: 150px;line-height: 26px;">{:str_replace(",",PHP_EOL, $shop.refund_reason2)}</textarea>
									</div>
									<div class="layui-form-mid layui-word-aux span_note">
										一行一个
									</div>
								</div>
				            </div>
							<div class="layui-form-item">
								<label class="layui-form-label">开票开关：</label>
								<div class="layui-input-inline w120">
									<select name="m_is_bill" lay-filter="m_bill">
										<option value="1" {eq name="$shop.is_bill" value="1"}selected{/eq}>开启</option>
										<option value="0" {eq name="$shop.is_bill" value="0"}selected{/eq}>关闭</option>
									</select>
								</div>
							</div>
							<div class="layui-form-item" id="span_bill" {eq name="$shop.is_bill" value="0"}style="display: none;"{/eq}>
								<label class="layui-form-label">开票有效期：</label>
								<div class="layui-input-inline" style="width: 120px;">
									<select name="m_bill_time">
										<option value="0" {eq name="$shop.bill_time" value="1"}selected{/eq}>不限</option>
										<option value="1" {eq name="$shop.bill_time" value="1"}selected{/eq}>1个月</option>
										<option value="3" {eq name="$shop.bill_time" value="3"}selected{/eq}>3个月</option>
										<option value="6" {eq name="$shop.bill_time" value="6"}selected{/eq}>6个月</option>
										<option value="12" {eq name="$shop.bill_time" value="12"}selected{/eq}>1年</option>
									</select>
								</div>
								<div class="layui-form-mid layui-word-aux">内的订单可开票</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="m_footer">
			<button class="layui-btn layui-btn-normal" lay-submit lay-filter="LAY-submit">提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
    </form>
</div>
</body>
</html>
<script src="{__STATIC__}/layuiAdmin/layui/layui.js"></script>
<script>
	layui.config({
		base: '{__STATIC__}/layuiAdmin/' // 静态资源所在路径
	}).use(['index','form'], function(){
		let $ = layui.$;
		let layer = layui.layer;
		let form = layui.form;

		/* 监听select */
		form.on('select(m_exchange)',function (data) {
			if(data.value==0){
				$("#span_exchange").hide();
			}
			else {
				$("#span_exchange").show();
			}
		});
		form.on('select(m_free)',function (data) {
			if(data.value==0){
				$("#span_free").hide();
			}
			else {
				$("#span_free").show();
			}
		});
		form.on('select(m_refund)',function (data) {
			if(data.value==0){
				$("#span_refund").hide();
			}
			else {
				$("#span_refund").show();
			}
		});
		form.on('select(m_bill)',function (data) {
			if(data.value==0){
				$("#span_bill").hide();
			}
			else {
				$("#span_bill").show();
			}
		});

		/* 监听提交 */
		form.on('submit(LAY-submit)', function(data){
			let field = data.field; //获取提交的字段
			let m_refund_reason1 = field.m_refund_reason1.replace(/\n/g,',');
			let m_refund_reason2 = field.m_refund_reason2.replace(/\n/g,',');
			$.ajax({
				type:"post",
				url:"saveShop.html",
				data: {
					default_stock:field.m_default_stock,
					warning_stock:field.m_warning_stock,
					is_exchange:field.m_exchange,
					exchange_ratio:field.m_exchange_ratio,
					mini_integral:field.m_mini_integral,
					use_ratio:field.m_use_ratio,
					close_time:field.m_close_time,
					send_time:field.m_send_time,
					finish_time:field.m_finish_time,
					is_free_shipping:field.m_free_shipping,
					free_price:field.m_free_price,
					is_refund:field.m_is_refund,
					refund_time:field.m_refund_time,
					refund_name:field.m_refund_name,
					refund_tel:field.m_refund_tel,
					refund_address:field.m_refund_address,
					refund_reason1:m_refund_reason1,
					refund_reason2:m_refund_reason2,
					is_bill:field.m_is_bill,
					bill_time:field.m_bill_time,
				},
				dataType:"json",
				beforeSend: function () {
					layer.load(1);
				},
				success:function(res){
					layer.closeAll(); //关闭弹层
					if(res.code == 0){
						layer.msg('修改成功', {
							time: 2000
						}, function(){
							location.reload();
						});
					}
					else {
						layer.msg(res.msg);
					}
				}
			});
			return false;
		});
	});
</script>